package com.maxatime.service.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.maxatime.pojo.entity.SysUser;
import com.maxatime.dao.SysUserMapper;
import com.maxatime.service.ISysUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author Ssb
 * @since 2024-07-15
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
    @Autowired
    SysUserMapper sysUserMapper;
    @Override
    public Map<String, Object> map(SysUser sysUser) {
        PageHelper.startPage(sysUser.getPageNum(), sysUser.getPageSize());
        List<SysUser> list = sysUserMapper.list(sysUser);
        PageInfo<SysUser> pageinfo = new PageInfo<SysUser>(list);
        Map<String, Object> m = new HashMap<>();
        m.put("list", list);
        m.put("pageInfo", pageinfo);
        return m;
    }

    @Override
    public int insertSelective(SysUser sysUser) {

        LocalDateTime dateTime = LocalDateTime.of(2024, 7, 16, 9, 30, 0);
        sysUser.setCreateTime(dateTime);
        sysUser.setCreateBy("admin");
        sysUser.setUpdateBy("admin");
        sysUser.setDelFlag("0");
        sysUser.setStatus("0");
        sysUserMapper.insertSelective(sysUser);
        return 0;
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        sysUserMapper.deleteByPrimaryKey(id);
        return 0;
    }

    @Override
    public SysUser find(int id) {
        return sysUserMapper.find(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SysUser sysUser) {
        sysUserMapper.updateByPrimaryKeySelective(sysUser);
        return 0;
    }


}
